//
//  Rss.h
//  RssReader
//
//  Created by 曙光 王 on 12-4-24.
//  Copyright (c) 2012年 Dawn. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ASIHTTPRequest.h"

@protocol RssDelegate;
@interface Rss : NSObject<ASIHTTPRequestDelegate,ASIProgressDelegate>{
@private
    NSString *configFilePath;
    NSString *channelsPath;
    NSMutableArray *channels;
	NSString *channelDateFilePath;
    BOOL cache;
	id delegate;
}
@property (nonatomic,retain) NSString *configFilePath;
@property (nonatomic,retain) NSString *channelsPath;
@property (nonatomic,assign) id<RssDelegate> delegate;
@property (retain) NSMutableArray *channels;
@property (nonatomic,retain) NSString *channelDateFilePath;
+ (id) shareRss;
- (NSString *)channelPathForKey:(NSString *)key;
- (void) updateChannel:(NSInteger)channelIndex;
- (void) updateChannelNow:(NSInteger)channelIndex;
- (void) downloadChannel:(NSInteger)channelIndex;
- (void) cacheChannels;
- (void) cacheNextChannel;
- (void) saveConfig;
- (void) addChannel:(NSString *)url;
@end

@protocol RssDelegate
@optional
- (void) updateDidFinishedWithData:(NSArray *)data withNet:(BOOL)net;
- (void) updateDidFailed;
- (void) updateingWithProgress:(float)progress;
- (void) cacheWithProgress:(float)progress;
- (void) cacheWithDataLength:(long long)dataLength;
- (void) cacheWithChannelTitle:(NSString *)title;
- (void) channelAddedFailed:(NSString *)errorMsg;
- (void) channelAdded:(NSDictionary *)dict;
@end
